/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vn.ugame.utility;

import java.util.Random;

/**
 *
 * @author user
 */
public class RandomString {

    private static RandomString instance;

    public static RandomString getInstance() {
        if (instance == null) {
            instance = new RandomString();
        }
        return instance;
    }

    public String getRandomString(int length) {
//        String uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
//        String lowercase = "abcdefghijklmnopqrstuvwxyz";
//        String number = "0123456789";
//        String special = "!@#$%^&*";

        String str = "QAa0bcLdUK2eHfJgTP8XhiFj61DOklNm9nBoI5pGqYVrs3CtSuMZvwWx4yE7zR";
        StringBuilder sb = new StringBuilder();
        Random r = new Random();
        int index = 0;
        for (int i = 1; i <= length; i++) {
            index = r.nextInt(str.length());
            sb.append(str.charAt(index));
        }
        return sb.toString();
    }
}
